<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('福利流程')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>

</head>
<style>
    .select-list li p {

        margin: 4px 0px 5px 0px;
    !important;
    }

    .fixed-table-container .bs-checkbox .th-inner {
        padding: 8px 8px !important;
    }
</style>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>工号：</p>
                            <input type="text" name="badge"/>
                        </li>
                        <li>
                            <p>姓名：</p>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>


        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-primary" onclick="increase('cSP_BenefitMonthInit',1)" shiro:hasPermission="system:benefitbase:add">
                <i class="fa fa-plus"></i> 初始化
            </a>
            <a class="btn btn-success" onclick="increase('cSP_BenefitMonthCalc',1)" shiro:hasPermission="system:benefitbase:add">
                <i class="fa fa-windows"></i> 计算
            </a>
            <a class="btn btn-info" onclick="increase('cSP_BenefitMonthFrozen')" shiro:hasPermission="system:benefitbase:add">
                <i class="fa fa-caret-right"></i> 冻结
            </a>
            <a class="btn btn-warning" onclick="increase('cSP_BenefitMonthUnFrozen')" shiro:hasPermission="system:benefitbase:add">
                <i class="fa fa-times"></i> 取消冻结
            </a>
            <a class="btn btn-danger" onclick="increase('cSP_BenefitMonthClosed',1)" shiro:hasPermission="system:benefitbase:add">
                <i class="fa fa-download"></i> 封账
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>

<script th:inline="javascript">
    var prefix = ctx + 'welfare/calculation';
    $(function () {
        queryData();


    });
    function increase (storage,z) {
        var allId = "";
        var row = $("#bootstrap-table").bootstrapTable('getSelections');

        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allId += row[i].id
            } else {
                allId += row[i].id + ","

            }
        };

        if (row.length == 0) {
            $.modal.alertWarning("请选择数据!");
            return;
        } else {
            $.ajax({
                async: false,
                url: prefix + "/procedure",
                data: {
                    allid: allId,
                    procedure: storage
                },
                type: "post",
                dataType: "json",
                success: function (data) {
                    if (data.code == 0) {
                        $.modal.alertWarning("操作成功！");
                        $("#bootstrap-table").bootstrapTable("refresh");

                        $(".layui-layer-btn0").click(function () {
                            if(z==1){
                                $(".btn-warning", parent.document).click();
                                $.modal.close();
                            }
                        });

                    } else if (data.code == 500) {
                        $.modal.alertWarning("服务器繁忙！");
                        $("#bootstrap-table").bootstrapTable("refresh");
                    } else {
                        $.modal.alertWarning(data.message);
                        $("#bootstrap-table").bootstrapTable("refresh");
                    }

                },
            });
        }
    }

    function queryData() {
        var columns = [];
        var checkbox = {checkbox: true};
        var id = {field: 'id', title: '序号'};
        var pzid = {field: 'pzid', title: '薪资区域'};
        var xzt = {field: 'xzt', title: '薪资套'};
        var term = {field: 'term', title: '月份'};
        var BeginDate = {field: 'BeginDate', title: '开始时间'};
        var EndDate = {field: 'EndDate', title: '结束时间'};
        var initialized = {
            field: 'initialized',
            title: '初始化',
            formatter: function (value, row, index) {
                if (row.initialized == 1) {
                    return '<i class=\"fa fa-toggle-on text-info fa-2x\" ></i> ';
                } else {
                    return '<i class=\"fa fa-toggle-off text-info fa-2x\" ></i> ';
                }
            }

        };
        var initializedby = {field: 'initializedby', title: '谁初始化'};
        var initializedTime = {field: 'initializedTime', title: '初始化时间'};
        var submit = {
            field: 'submit',
            title: '计算',
            formatter: function (value, row, index) {
                if (row.submit == 1) {
                    return '<i class=\"fa fa-toggle-on text-info fa-2x\" ></i> ';
                } else {
                    return '<i class=\"fa fa-toggle-off text-info fa-2x\" ></i> ';
                }
            }
        };
        var submitBy = {field: 'submitBy', title: '谁计算'};
        var submitTime = {field: 'submitTime', title: '计算时间'};
        var frozen = {
            field: 'frozen',
            title: '冻结',
            formatter: function (value, row, index) {
                if (row.frozen == 1) {
                    return '<i class=\"fa fa-toggle-on text-info fa-2x\" ></i> ';
                } else {
                    return '<i class=\"fa fa-toggle-off text-info fa-2x\" ></i> ';
                }
            }

        };
        var frozenBy = {field: 'frozenBy', title: '谁冻结'};
        var frozenTime = {field: 'frozenTime', title: '冻结时间'};
        var closed = {
            field: 'closed',
            title: '封账',
            formatter: function (value, row, index) {
                if (row.closed == 1) {
                    return '<i class=\"fa fa-toggle-on text-info fa-2x\" ></i> ';
                } else {
                    return '<i class=\"fa fa-toggle-off text-info fa-2x\" ></i> ';
                }
            }
        };
        var closedBy = {field: 'closedBy', title: '谁封账'};
        var closedTime = {field: 'closedTime', title: '封账时间'};
        var remark = {field: 'remark', title: '备注'};
        columns.push(checkbox,id,pzid,xzt,term,BeginDate,EndDate,initialized,initializedby,initializedTime,submit,submitBy,submitTime,frozen,frozenBy,frozenTime,closed,closedBy,closedTime,remark);
        var options = {
            code: "PEID",
            uniqueId: "PEID",
            url: prefix + '/findWelfareProcess',
            modalName: "福利流程",
            height: $(window).height() - 110,
            columns: columns,
            pagination:false
        };
        $.table.init(options);
    }



    function submitHandler() {


    }


</script>
</body>
</html>